/*******************************************************************************
 * This program and the accompanying materials
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at 
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors:
 *     Peter Smith
 *******************************************************************************/
package org.boris.expr;


public class ExprError extends Expr
{
    public static final ExprError NULL = new ExprError("#NULL!", "Null Error");
    public static final ExprError DIV0 = new ExprError("#DIV/0!",
            "Divide by Zero Error");
    public static final ExprError VALUE = new ExprError("#VALUE", "Error in Value");
    public static final ExprError REF = new ExprError("#REF!", "Reference Error");
    public static final ExprError NAME = new ExprError("#NAME?",
            "Invalid Name Error");
    public static final ExprError NUM = new ExprError("#NUM!", "Number Error");
    public static final ExprError NA = new ExprError("#N/A", "Value not Available");

    private String errType;
    private String message;
    private Exception exception;

    public ExprError(String type, String message) {
        super(ExprType.Error, false);
        this.errType = type;
        this.message = message;
    }
    
    public ExprError(Exception e) {
        super(ExprType.Error, false);
        this.errType = "#ERR!";
        this.message = e.getMessage();
        this.exception = e;
    }

    public String getErrType() {
        return errType;
    }

    public String getMessage() {
        return message;
    }
    
    public Exception getException() {
        return exception;
    }

    public String toString() {
        return "#" + message;
    }
}
